Skip to content

Comments

feat: add durable-functions integration#7535

Open
ojproductions wants to merge 30 commits intomasterfrom
onzia/azure-durable-functions
Open

feat: add durable-functions integration#7535
ojproductions wants to merge 30 commits intomasterfrom
onzia/azure-durable-functions

Conversation

@ojproductions
Copy link

@ojproductions ojproductions commented Feb 13, 2026

What does this PR do?

Adds auto instrumentation for azure durable-functions package

  • Instruments Activity and Entity operations
  • Purposely does not instrument orchestrator functions
    • It was found orchestrators dont play well with instrumentation due to non-deterministic functionality
  • Tests

Motivation

APMSVLS-332
SVLS-7644

Additional Notes

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Overall package size

Self size: 4.79 MB
Deduped: 5.63 MB
No deduping: 5.63 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 816.75 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 18.60465% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.21%. Comparing base (c69f877) to head (32d5a54).

Files with missing lines Patch % Lines
...og-instrumentations/src/azure-durable-functions.js 21.73% 18 Missing ⚠️
...atadog-plugin-azure-durable-functions/src/index.js 18.75% 13 Missing ⚠️
...ages/datadog-instrumentations/src/helpers/hooks.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/plugins/index.js 0.00% 1 Missing ⚠️
...-trace/src/service-naming/schemas/v0/serverless.js 0.00% 1 Missing ⚠️
...-trace/src/service-naming/schemas/v1/serverless.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7535      +/-   ##
==========================================
- Coverage   80.30%   80.21%   -0.09%     
==========================================
  Files         733      735       +2     
  Lines       31565    31608      +43     
==========================================
+ Hits        25348    25355       +7     
- Misses       6217     6253      +36     
Flag Coverage Δ
aiguard-macos 38.95% <0.00%> (-0.12%) ⬇️
aiguard-ubuntu 39.07% <0.00%> (-0.12%) ⬇️
aiguard-windows 38.80% <0.00%> (-0.12%) ⬇️
apm-capabilities-tracing-macos 48.59% <15.78%> (-0.03%) ⬇️
apm-capabilities-tracing-ubuntu 48.62% <15.78%> (-0.03%) ⬇️
apm-capabilities-tracing-windows 48.31% <15.78%> (-0.04%) ⬇️
apm-integrations-child-process 38.52% <0.00%> (-0.12%) ⬇️
apm-integrations-couchbase-18 37.29% <0.00%> (-0.26%) ⬇️
apm-integrations-couchbase-eol 37.91% <0.00%> (+0.03%) ⬆️
apm-integrations-oracledb 37.74% <0.00%> (-0.11%) ⬇️
appsec-express 55.52% <0.00%> (-0.09%) ⬇️
appsec-fastify 51.84% <0.00%> (-0.09%) ⬇️
appsec-graphql 52.03% <0.00%> (-0.08%) ⬇️
appsec-kafka 44.47% <0.00%> (-0.10%) ⬇️
appsec-ldapjs 44.10% <0.00%> (-0.10%) ⬇️
appsec-lodash 43.79% <0.00%> (-0.09%) ⬇️
appsec-macos 58.61% <0.00%> (-0.08%) ⬇️
appsec-mongodb-core 48.85% <0.00%> (-0.09%) ⬇️
appsec-mongoose 49.65% <0.00%> (-0.09%) ⬇️
appsec-mysql 51.02% <0.00%> (-0.08%) ⬇️
appsec-node-serialize 43.30% <0.00%> (-0.10%) ⬇️
appsec-passport 47.79% <0.00%> (-0.10%) ⬇️
appsec-postgres 50.75% <0.00%> (-0.11%) ⬇️
appsec-sourcing 42.65% <0.00%> (-0.10%) ⬇️
appsec-template 43.47% <0.00%> (-0.10%) ⬇️
appsec-ubuntu 58.69% <0.00%> (-0.08%) ⬇️
appsec-windows 58.47% <0.00%> (-0.06%) ⬇️
instrumentations-instrumentation-bluebird 32.22% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-body-parser 40.53% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-child_process 37.84% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-cookie-parser 34.26% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-express 34.60% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.39% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-express-session 40.15% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-fs 31.83% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-generic-pool 29.81% <0.00%> (-0.02%) ⬇️
instrumentations-instrumentation-http 39.87% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-knex 32.23% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-mongoose 33.39% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-multer 40.27% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-mysql2 38.31% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-passport 44.10% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-passport-http 43.77% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-passport-local 44.32% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-pg 37.73% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-promise 32.15% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-promise-js 32.16% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-q 32.20% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-url 32.12% <0.00%> (-0.12%) ⬇️
instrumentations-instrumentation-when 32.17% <0.00%> (-0.12%) ⬇️
llmobs-ai 41.48% <0.00%> (+0.03%) ⬆️
llmobs-anthropic 40.34% <0.00%> (-0.11%) ⬇️
llmobs-bedrock 39.27% <0.00%> (-0.10%) ⬇️
llmobs-google-genai 39.86% <0.00%> (-0.10%) ⬇️
llmobs-langchain 39.44% <0.00%> (-0.09%) ⬇️
llmobs-openai 44.15% <0.00%> (-0.10%) ⬇️
llmobs-vertex-ai 40.05% <0.00%> (-0.11%) ⬇️
platform-core 29.65% <0.00%> (-0.07%) ⬇️
platform-esbuild 32.83% <0.00%> (-0.07%) ⬇️
platform-instrumentations-misc 40.49% <0.00%> (-0.05%) ⬇️
platform-shimmer 36.08% <0.00%> (-0.07%) ⬇️
platform-unit-guardrails 31.21% <0.00%> (-0.07%) ⬇️
plugins-azure-durable-functions 23.90% <20.83%> (?)
plugins-azure-event-hubs 23.98% <0.00%> (-0.04%) ⬇️
plugins-azure-service-bus 23.39% <0.00%> (-0.04%) ⬇️
plugins-bullmq 43.62% <0.00%> (-0.11%) ⬇️
plugins-cassandra 37.78% <0.00%> (-0.11%) ⬇️
plugins-cookie 25.04% <0.00%> (-0.05%) ⬇️
plugins-cookie-parser 24.83% <0.00%> (-0.05%) ⬇️
plugins-crypto 24.67% <0.00%> (-0.06%) ⬇️
plugins-dd-trace-api 38.38% <0.00%> (-0.12%) ⬇️
plugins-express-mongo-sanitize 25.00% <0.00%> (-0.05%) ⬇️
plugins-express-session 24.79% <0.00%> (-0.05%) ⬇️
plugins-fastify 42.28% <0.00%> (-0.11%) ⬇️
plugins-fetch 38.33% <0.00%> (-0.11%) ⬇️
plugins-fs 38.63% <0.00%> (-0.12%) ⬇️
plugins-generic-pool 24.02% <0.00%> (-0.04%) ⬇️
plugins-google-cloud-pubsub 45.44% <0.00%> (-0.13%) ⬇️
plugins-grpc 40.98% <0.00%> (-0.11%) ⬇️
plugins-handlebars 25.04% <0.00%> (-0.05%) ⬇️
plugins-hapi 40.16% <0.00%> (-0.11%) ⬇️
plugins-hono 40.42% <0.00%> (-0.11%) ⬇️
plugins-ioredis 38.43% <0.00%> (-0.12%) ⬇️
plugins-knex 24.76% <0.00%> (-0.04%) ⬇️
plugins-ldapjs 22.58% <0.00%> (-0.04%) ⬇️
plugins-light-my-request 24.44% <0.00%> (-0.04%) ⬇️
plugins-limitd-client 32.52% <0.00%> (-0.12%) ⬇️
plugins-lodash 24.09% <0.00%> (-0.04%) ⬇️
plugins-mariadb 39.51% <0.00%> (-0.12%) ⬇️
plugins-memcached 38.16% <0.00%> (-0.12%) ⬇️
plugins-microgateway-core 39.19% <0.00%> (-0.11%) ⬇️
plugins-moleculer 40.54% <0.00%> (-0.11%) ⬇️
plugins-mongodb 39.21% <0.00%> (-0.11%) ⬇️
plugins-mongodb-core 39.04% <0.00%> (-0.12%) ⬇️
plugins-mongoose 38.87% <0.00%> (-0.11%) ⬇️
plugins-multer 24.79% <0.00%> (-0.05%) ⬇️
plugins-mysql 39.18% <0.00%> (-0.12%) ⬇️
plugins-mysql2 39.28% <0.00%> (-0.12%) ⬇️
plugins-node-serialize 25.08% <0.00%> (-0.05%) ⬇️
plugins-opensearch 37.61% <0.00%> (-0.11%) ⬇️
plugins-passport-http 24.87% <0.00%> (-0.04%) ⬇️
plugins-postgres 35.71% <0.00%> (-0.10%) ⬇️
plugins-process 24.67% <0.00%> (-0.06%) ⬇️
plugins-pug 25.04% <0.00%> (-0.05%) ⬇️
plugins-redis 38.90% <0.00%> (-0.12%) ⬇️
plugins-router 43.18% <0.00%> (+0.03%) ⬆️
plugins-sequelize 23.62% <0.00%> (-0.04%) ⬇️
plugins-test-and-upstream-amqp10 38.50% <0.00%> (+0.03%) ⬆️
plugins-test-and-upstream-amqplib 43.91% <0.00%> (-0.12%) ⬇️
plugins-test-and-upstream-apollo 39.04% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-avsc 38.72% <0.00%> (-0.12%) ⬇️
plugins-test-and-upstream-bunyan 33.82% <0.00%> (-0.12%) ⬇️
plugins-test-and-upstream-connect 40.83% <0.00%> (-0.11%) ⬇️
plugins-test-and-upstream-graphql 40.16% <0.00%> (-0.12%) ⬇️
plugins-test-and-upstream-koa 40.41% <0.00%> (-0.11%) ⬇️
plugins-test-and-upstream-protobufjs 38.95% <0.00%> (-0.12%) ⬇️
plugins-test-and-upstream-rhea 44.14% <0.00%> (-0.12%) ⬇️
plugins-undici 39.12% <0.00%> (-0.11%) ⬇️
plugins-url 24.67% <0.00%> (-0.06%) ⬇️
plugins-valkey 38.05% <0.00%> (-0.15%) ⬇️
plugins-vm 24.67% <0.00%> (-0.06%) ⬇️
plugins-winston 34.02% <0.00%> (-0.11%) ⬇️
plugins-ws 41.93% <0.00%> (-0.11%) ⬇️
profiling-macos 39.86% <0.00%> (-0.11%) ⬇️
profiling-ubuntu 39.99% <0.00%> (-0.11%) ⬇️
profiling-windows 41.21% <0.00%> (-0.11%) ⬇️
serverless-azure-functions-client 23.71% <0.00%> (-0.04%) ⬇️
serverless-azure-functions-eventhubs 23.71% <0.00%> (-0.04%) ⬇️
serverless-azure-functions-servicebus 23.71% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1

This comment has been minimized.

@jcstorms1
Copy link
Contributor

@codex review

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@ojproductions
Copy link
Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38dad4ce27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return function (activityName, activityOptions) {
shimmer.wrap(activityOptions, 'handler', handler => {
const isAsync =
handler && handler.constructor && handler.constructor.name === 'AsyncFunction'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle promise-returning activity handlers as async

The activity wrapper chooses traceSync unless handler.constructor.name === 'AsyncFunction', which misses valid handlers that return a Promise but are not declared with async (for example transpiled async functions or plain functions returning Promise). In that case the span is finished on end before the Promise settles, so latency and rejection errors are not captured for the activity execution.

Useful? React with 👍 / 👎.

type: 'serverless',

meta: {
component: 'azure-functions',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the durable-functions component tag

The plugin starts spans for azure-durable-functions but explicitly sets meta.component to azure-functions, overriding the plugin component and labeling these spans as the wrong integration. This causes durable-function traces to be attributed to the Azure Functions integration instead of their own component.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, are we considering these to be the same component as standard azure functions or should we make this have a more specific component tag for durable functions?

@pr-commenter
Copy link

pr-commenter bot commented Feb 15, 2026

Benchmarks

Benchmark execution time: 2026-02-24 15:07:10

Comparing candidate commit 32d5a54 in PR branch onzia/azure-durable-functions with baseline commit c69f877 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics.

@ojproductions ojproductions marked this pull request as ready for review February 18, 2026 14:51
@ojproductions ojproductions requested review from a team as code owners February 18, 2026 14:51
@ojproductions ojproductions requested review from khanayan123 and removed request for a team February 18, 2026 14:51
addHook({ name: '@azure/functions', versions: ['>=4'], patchDefault: false }, (azureFunction) => {
const { app } = azureFunction

if (alreadyPatched) return azureFunction
Copy link
Author

@ojproductions ojproductions Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason, when using esm imports, azure functions gets patched twice, resulting in extra spans. hence I added this. Why does this happen?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ESM we always patch both the default export and the outer export.

In some cases, the default export and the outer export end up triggering a patch on the same object or function. For example, we observed this behavior when a patch was applied to the prototype of an object that was shared by both the default export and the outer export.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the patchDefault: false option in addhook not affect this behavior at all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I solved this in service bus by using a weakmap like this. I'm not sure if that's the approach we want to take here though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me and @pabloerhard talked and it seems this may be due to how durable-functions is importing @azure/functions under the hood using require. He's working on a fix in #7601

Copy link
Contributor

@jcstorms1 jcstorms1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Left a few questions and a couple suggestions. Nice job!

type: 'serverless',

meta: {
component: 'azure-functions',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, are we considering these to be the same component as standard azure functions or should we make this have a more specific component tag for durable functions?

super.finish(ctx)
}

asyncEnd (ctx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it seems strange, but it is better to make this asyncStart for a more accurate trace. My initial intuition was to use these to capture the end of traceAsync, but I was corrected as well.

asyncStart and asyncEnd are essentially occurring right after each other without anything happening in-between. In fact, asyncEnd isn't necessary in the majority of cases. The edge case would be if we need information from a call back function, which we do not patch in this integration.

start
code patched
end
asyncStart
if there was a callback it would execute here.
asyncEnd

kind: 'internal',
type: 'serverless',

meta: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you have this in a doc or not, but I'd double check we have all the metadata we need and compare it with a normal function. I imagine a lot of the Azure tags won't be necessary for durable functions, but we should make sure there is as much in common as possible.

await agent.stop()
})

it('is instrumented', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a separate test for entity and non-entity functions or is this sufficient? I believe there is separate logic in the case of an entity function and we should probably capture that.

async function spawnPluginIntegrationTestProc (cwd, command, args, agentPort, stdioHandler, additionalEnvArgs = {}) {
let env = {
NODE_OPTIONS: `--loader=${hookFile} func start`,
NODE_OPTIONS: `--loader=${hookFile}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does func start initialize now? I may have missed it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured this was a typo, as the func start command is getting passed in on line 45 & 68, then initialized on line 91. Does passing it to NODE_OPTIONS do anything?

@ojproductions ojproductions changed the title Onzia/azure durable functions feat: add durable-functions integration Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants